package com.study.daily.algozuo.y2021.m10.day1020;

/**
 * EvenTimeAndOddTime
 *
 * @author Tom on 2021/10/20
 */
public class Code05_EvenTimeAndOddTime {
    public static void main(String[] args) {

    }

    public static int onlyOneEvenTime(int[] nums) {
        int ans = 0;
        for (int num: nums) {
            ans ^= num;
        }
        return ans;
    }
    public static int OnlyTwoEvenTime(int[] nums){
        int exor = 0;
        for(int num: nums){
            exor ^= num;
        }
        int rightestOne = exor & (-exor);
        int one = 0;
        for(int num: nums){
            if((rightestOne&num) == 0){
                one ^= num;
            }
        }
        return exor ^ one;
    }
}
